package JavaSe;

import java.lang.reflect.Field;

/**
 * @author VX5
 * @Title: MJC
 * @ProjectName DataStructure
 * @Description: TODO
 * @date ${DAT}11:13
 */
public class Obj implements Cloneable {
    private int index = 0;

    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }

    public Object clone(){
        Object o = null;
        try {
            o = (Obj)super.clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        return o;
    }

    static class B{
        public static void main(String[] args) throws IllegalAccessException, InstantiationException, NoSuchFieldException {
            Obj a = new Obj();
            Obj b = (Obj) a.clone();
            b.setIndex(2);
            System.out.println(a.getIndex());
            System.out.println(b.getIndex());
            Obj newi = Obj.class.newInstance();
            Class A = Obj.class;
            Class AA  = a.getClass();
            Field field = A.getField("index");
            field.setAccessible(true);
            System.out.println(field.getName()+":"+field.getType().getName());
            System.out.println(newi.getIndex());
        }
    }
}
